package com.cat.mrli.rat.programs;

import android.content.Context;
import android.opengl.GLES20;

import com.cat.mrli.rat.R;

import static android.opengl.GLES20.*;

/**
 * Created by mrli on 2017/6/25.
 */

public class ColorShaderProgram extends ShaderProgram {
    private final int uMatrixLocation;
    private final int aPosition;
    private final int uColorLocation;

    public ColorShaderProgram(Context context) {
        super(context, R.raw.base_vertex_shader, R.raw.base_fragment_shader);
        uMatrixLocation = glGetUniformLocation(program, U_MATRIX);
        aPosition = GLES20.glGetAttribLocation(program, A_POSITION);
        uColorLocation = glGetUniformLocation(program, U_COLOR);
    }


    public void setUniforms(float[] matrix, float r, float g, float b) {
        glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
        glUniform4f(uColorLocation, r, g, b, 1f);
    }


    public int getPositionAttributeLocation() {
        return aPosition;
    }

}
